﻿/***********************************************************************
 * <copyright file="ValidateEmailAttribute.cs" company="BUCA JSC">
 * -->    Copyright (C) statement. All right reserved
 * </copyright>
 * 
 * Created:   LinhMC
 * Email:    linhmc@buca.vn
 * Website:
 * Create Date: Friday, October 18, 2013
 * Usage: 
 * 
 * RevisionHistory: 
 * Date         Author               Description 
 * 
 * ************************************************************************/

using System.ComponentModel.DataAnnotations;

namespace FABigTimeMvc.Code.Attributes
{
    /// <summary>
    /// Custom annotation attribute.
    /// Used to validate Email addresses.
    /// </summary>
    public class ValidateEmailAttribute : RegularExpressionAttribute
    {
        /// <summary>
        /// Constructor of ValidateEmailAttribute.
        /// </summary>
        public ValidateEmailAttribute() :
            base("^([a-zA-Z0-9_\\-\\.\\+]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$")
        {
            ErrorMessage = "Invalid email address";
        }

    }
}